<div class="alert-title">添加代理</div>

<table class="daili-info">
    <tr>
        <td class="title">代理账号</td>
        <td class="field">
            <input type="text" class="am-form-field" name="account" placeholder="代理登录账号"/>
        </td>
        <td class="copy"></td>
    </tr>
    <tr>
        <td class="title">登录密码</td>
        <td class="field">
            <input type="password" class="am-form-field" name="login-password" placeholder="代理登录密码"/>
        </td>
        <td class="copy"></td>
    </tr>

    <tr>
        <td class="title">代理名称</td>
        <td class="field">
            <input type="text" class="am-form-field" name="realname" placeholder="请输入代理的真实姓名">
        </td>
        <td class="copy"></td>
    </tr>

    <tr>
        <td class="title">代理模式</td>
        <td class="field peilv">
            <label class="am-radio-inline">
                <input type="radio" name="peilv" value="2" data-am-ucheck checked> 分红
            </label>
            <label class="am-radio-inline">
                <input type="radio" name="peilv" value="1" data-am-ucheck> 赔率差
            </label>
        </td>
        <td class="copy"></td>
    </tr>
</table>

<div class="button_line">
    <button class="btn-save admin_button">确定</button>
    <button class="close admin_button">取消</button>
</div>
<style type="text/css">
    .daili-info .title {
        width: 100px !important;
    }
    .daili-info {
        width: 100%;
    }
    .daili-info td {
        padding: 5px;
    }
</style>

<script>
    $(".button_line .close").click(function() {
        $("#add_daili").remove();
    });
    $(".button_line .btn-save").click(function() {
        var account = $(".daili-info input[name='account']").val().trim();
        var p = $(".daili-info input[name='login-password']").val().trim();
        var realname = $(".daili-info input[name='realname']").val().trim();
        if (!account) {
            alert2("请输入代理账号名称", true);
            return;
        }
        if (!p) {
            alert2("请输入代理登录密码", true);
            return;
        }
        if (!realname) {
            alert2("请输入代理真实名字", true);
            return;
        }

        var refereeType = $(".peilv input:checked").val();
        startLoading();
        CMD.add_referee(account, p, realname, refereeType, function(r) {
            stopLoading();
            if (!r || typeof(r) == 'string') {
                alert2(r, true);
            }
            else {
                $("#add_daili").remove();
                _f();
                alert2("代理添加成功！");
            }
        })
    })
</script>